<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="renderer" content="webkit">

    <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
    <title>Title</title>
</head>
<body>
<div id="test">
    <button class="ajaxbtn">获取数据</button>
    <button class="ajaxbtn">获取数据2</button>
    <button class="ajaxbtn">获取数据3</button>
</div>

点击次数<span id="num"></span>
<div id="show">

</div>

<script>
    //定义点击次数和方法执行次数
    (function () {
        var Time;
        var a = 1;
        var flag = 1;

        $('#test').click(function () {
            clearTimeout(Time)
            Time = setTimeout(function () {
                console.log("hhh")
            },100)
        })
    })()

    //封装ajax事件
    function btnAjax(url, cb) {

        $.ajax({
            type: 'get',
            url: url,
            dataType: 'jsonp',
            success: function (data) {
                var func = callbackFunc(data, cb);
                func()
            }
        })
    }
    //返回函数
    function cb(data) {
        console.log(a);
        console.log(data);
        // var str = '';
        // for (var i = 0; i < data.subjects.length; i++) {
        //     str += '<img src="' + data.subjects[i].images.small + '">';
        // }
        // $('#show').html(str)
    }
    //判断次数，获取返回函数
    function callbackFunc(data, cb) {
        flag++;
        if (a == flag) {
            return function () {
                cb(data);
            }
        } else {
            return function () {
            }
        }
    }
</script>
<script>
    var n = new Number(1)
    var n2 = 2
    console.log(n,n2)
</script>
</body>
</html>